package com.skzh.web.controller.equipment;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import com.skzh.common.core.domain.model.LoginUser;
import com.skzh.common.utils.SecurityUtils;
import com.skzh.equipment.domain.HailerAnnouncement;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;
import com.skzh.common.annotation.Log;
import io.swagger.annotations.ApiOperation;
import com.skzh.common.core.controller.BaseController;
import com.skzh.common.core.domain.AjaxResult;
import com.skzh.common.enums.BusinessType;
import com.skzh.equipment.domain.HailerInfo;
import com.skzh.equipment.service.IHailerInfoService;
import com.skzh.common.utils.poi.ExcelUtil;
import com.skzh.common.core.page.TableDataInfo;

/**
 * 喊话器设备信息Controller
 *
 * @author skzh
 * @date 2025-03-21
 */
@RestController
@RequestMapping("/equipment/hailer")
public class HailerInfoController extends BaseController {
    @Autowired
    private IHailerInfoService hailerInfoService;

    /**
     * 查询喊话器设备信息列表
     */
    @ApiOperation(value = "查询喊话器设备信息列表")
    @PreAuthorize("@ss.hasPermi('equipment:hailer:list')")
    @GetMapping("/list" )
    public TableDataInfo list(HailerInfo hailerInfo) {
        startPage();
        List<HailerInfo> list = hailerInfoService.selectHailerInfoList(hailerInfo);
        return getDataTable(list);
    }

    /**
     * 导出喊话器设备信息列表
     */
    @ApiOperation(value = "导出喊话器设备信息列表")
    @PreAuthorize("@ss.hasPermi('equipment:hailer:export')" )
    @Log(title = "喊话器设备信息" , businessType = BusinessType.EXPORT)
    @PostMapping("/export" )
    public void export(HttpServletResponse response, HailerInfo hailerInfo) {
        List<HailerInfo> list = hailerInfoService.selectHailerInfoList(hailerInfo);
        ExcelUtil<HailerInfo> util = new ExcelUtil<HailerInfo>(HailerInfo. class);
        util.exportExcel(response, list, "喊话器设备信息数据" );
    }

    /**
     * 获取喊话器设备信息详细信息
     */
    @ApiOperation(value = "获取喊话器设备信息详细信息")
    @PreAuthorize("@ss.hasPermi('equipment:hailer:query')" )
    @GetMapping(value = "/{id}" )
    public AjaxResult getInfo(@PathVariable("id" ) Long id) {
        return success(hailerInfoService.selectHailerInfoById(id));
    }

    /**
     * 新增喊话器设备信息
     */
    @ApiOperation(value = "新增喊话器设备信息")
    @PreAuthorize("@ss.hasPermi('equipment:hailer:add')" )
    @Log(title = "喊话器设备信息" , businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody HailerInfo hailerInfo) {
        LoginUser loginUser = SecurityUtils.getLoginUser();
        hailerInfo.setCreateBy(loginUser.getUsername());
        return toAjax(hailerInfoService.insertHailerInfo(hailerInfo));
    }

    /**
     * 修改喊话器设备信息
     */
    @ApiOperation(value = "修改喊话器设备信息")
    @PreAuthorize("@ss.hasPermi('equipment:hailer:edit')" )
    @Log(title = "喊话器设备信息" , businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody HailerInfo hailerInfo) {
        LoginUser loginUser = SecurityUtils.getLoginUser();
        hailerInfo.setUpdateBy(loginUser.getUsername());
        return toAjax(hailerInfoService.updateHailerInfo(hailerInfo));
    }

    /**
     * 删除喊话器设备信息
     */
    @ApiOperation(value = "删除喊话器设备信息")
    @PreAuthorize("@ss.hasPermi('equipment:hailer:remove')" )
    @Log(title = "喊话器设备信息" , businessType = BusinessType.DELETE)
    @DeleteMapping("/{ids}" )
    public AjaxResult remove(@PathVariable Long[] ids) {
        return toAjax(hailerInfoService.deleteHailerInfoByIds(ids));
    }

    /**
     * 查询喊话信息表
     */
    @ApiOperation(value = "查询喊话器设备信息列表")
    @PreAuthorize("@ss.hasPermi('equipment:hailer:list')")
    @GetMapping("/announcemente/list" )
    public TableDataInfo announcementeList() {
        startPage();
        List<HailerAnnouncement> list = hailerInfoService.selectHailerAnnouncementList();
        return getDataTable(list);
    }
}

    //喊话信息表
//    export function listHailerAnnouncemente(query) {
//    return request({
//            url: '/equipment/hailer/announcemente/list',
//            method: 'get',
//            params: query
//    })
//}
